package com.heima.article.controller.v1;

import com.heima.article.service.ApArticleService;
import com.heima.model.article.dtos.ArticleHomeDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: JW
 * @Description: TODO
 * @DateTime: 2022/1/22 19:14
 **/
@RestController
@RequestMapping("/api/v1/article")
public class ArticleHomeController {

    @Autowired
    private ApArticleService apArticleService;


    /**
     * @Author: JW
     * @Description:  TODO 默认加载
     * @Date: 20:40 2022/1/
     * @Param: [dto]
     * @return: com.heima.model.common.dtos.ResponseResult
    **/
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto dto){

        return apArticleService.getApArticle(3,dto);
    }

    /**
     * @Author: JW
     * @Description:  TODO 加载更多(加载以前的)
     * @Date: 20:49 2022/1/22
     * @Param: [dto]
     * @return: com.heima.model.common.dtos.ResponseResult
    **/
    @PostMapping("/loadmore")
    public ResponseResult loadmore(@RequestBody ArticleHomeDto dto){

        return apArticleService.getApArticle(1,dto);
    }

    /**
     * @Author: JW
     * @Description:  TODO 更新文章
     * @Date: 20:49 2022/1/22
     * @Param: [dto]
     * @return: com.heima.model.common.dtos.ResponseResult
    **/
    @PostMapping("/loadnew")
    public ResponseResult loadnew(@RequestBody ArticleHomeDto dto){

        return apArticleService.getApArticle(2,dto);
    }
}
